package com.scau.bookstore.api.controller;

import com.scau.bookstore.common.entity.Result;
import com.scau.bookstore.common.entity.StatusCode;
import com.scau.bookstore.api.util.FileUtil;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;


@RestController
public class FileController {
    @PostMapping("/upload")
    public Result test(@RequestBody MultipartFile image){
        FileUtil fileUtil = new FileUtil();
         String url = fileUtil.upload(image);
        return Result.builder().flag(true).code(StatusCode.OK).message("成功").data(url).build();
    }
}
